
limpa(4,1,24,80)
limpa(4,1,23,79,cor,.t.)
sele clientes
go top
declare cabeca[16], estrutura[16]
cabeca[1]  = 'CODIGO'       ; estrutura[01] = fiel(01)
cabeca[2]  = 'RAZAO SOCIAL' ; estrutura[02] = fiel(02)
cabeca[3]  = 'FANTASIA'     ; estrutura[03] = fiel(03)
cabeca[4]  = 'C.G.C.'       ; estrutura[04] = fiel(04)
cabeca[5]  = 'ENDERECO'     ; estrutura[05] = fiel(05)
cabeca[6]  = 'CIDADE'       ; estrutura[06] = fiel(06)
cabeca[7]  = 'UF'           ; estrutura[07] = fiel(07)
cabeca[8]  = 'C.E.P.'       ; estrutura[08] = fiel(08)
cabeca[09] = 'FONE-1'       ; estrutura[09] = fiel(09)
cabeca[10] = 'FONE-2'       ; estrutura[10] = fiel(10)
cabeca[11] = 'FAX'          ; estrutura[11] = fiel(11)
cabeca[12] = 'CONTATO'      ; estrutura[12] = fiel(12)
cabeca[13] = 'HONORARIO'    ; estrutura[13] = fiel(13)
cabeca[14] = 'DIA'          ; estrutura[14] = fiel(14)
cabeca[15] = 'ESTADUAL'     ; estrutura[15] = fiel(15)
cabeca[16] = 'CONTA'        ; estrutura[16] = fiel(16)
menu(24,1,' Inclui ',2,1)
menu(24,9,'Altera ',1,1)
menu(24,16,'Exclui ',1,1)
menu(24,23,'Relatorio ',1,1)
menu(24,33,'Reajustes ',4,1)
menu(24,43,'Recibo ',3,1)
menu(24,50,'Rojerio ',7,1)
menu(24,72,'Esc-Sai ',1,3)
apagou = .t.
while len(cabeca) > 0
  sele clientes
  set order to 2
  go top
  dbedit(5,2,22,78,estrutura,'cli100','@X',cabeca,.T.)
  if apagou = .f. 
     exit
  endif
enddo
retu
function cli100(modo,coluna)

set cursor on
if modo = 0
   retu(1)
elseif modo = 3
   retu(0)
endif
telalocal=savescreen(4,1,24,80)
tecla = lastkey()
do case
   case tecla = 5 .and. modo = 1

    mensa(10,'Inicio do arquivo ',2)
    retu(2)

   case tecla = 24 .and. modo = 2

    mensa(10,' Final do arquivo ',2)
    retu(2)

   case tecla = 27

    apagou = .f.
    retu(0)

   case tecla = 7

    adel(cabeca,coluna)
    adel(estrutura,coluna)
    retu(0)

   case tecla = 69 .or. tecla = 101

     sele clientes
     campo = fieldpos(estrutura[coluna])
     objeto = fieldget(campo)
     @ row(),col() get objeto
     read
     fieldput(campo,objeto)
     SKIP

   retu(2)
  case tecla = 73 .or. tecla = 105

    do while .t.
       sombra(8,6,22,78,'Inclusao')
       mclicodi = 0
       @ 10,8 say 'Cliente.......:' get mclicodi pict '999'
       read
       if empty(mclicodi)
          exit
       endif
       seek mclicodi
       if .not. eof()
          mensa(10,' Cliente ja cadastrado ',2)
          loop
       endif
       inicializa()
       telacli()
       read
       if confirma(18,60,' 1 - Confirma',' 2 - Cancela ')
          appe blank
          grava()
       endif
    enddo
    retu(2)

   case tecla = 65 .or. tecla = 97

     sele clientes
     mclicodi = clicodi
     sombra(8,6,22,77,' Alteracao ','')
     @ 10,8 say 'Cliente.......: ' + strzero(clicodi,3)
     inicializa()
     telacli()
     read
     if confirma(18,60,' 1 - Confirma ',' 2 - Cancela  ')
        grava()
     endif

   retu(2)

   case tecla = 69 .or. tecla = 101

     sele clientes
     sombra(8,6,22,77,' Exclusao ','')
     @ 10,8 say 'Cliente.......: ' + strzero(clicodi,3)
     inicializa()
     telacli()
     clear gets
     if confirma(18,55,' 1 - Exclui     ',' 2 - Nao exclui ')
        dele
        skip
     endif

   retu(2)

   case tecla = 82 .or. tecla = 114

   if .not. impressora()
      retu(2)
   endif
   sele clientes
   go top
   titulo = .T.  ; pag = 1  
   sombra(8,6,22,77,' Relatorio ','')
   do while .not. eof()
      set devi to screen
      @ 10,8 say 'Cliente..: ' + strzero(clicodi,3) + ' ' + clinome
      @ 11,8 say 'Fantasia : ' + clifant 
      set devi to printer
      if titulo
         tit_rela(' C L I E N T E S ',pag)
         titulo = .f.
      endif
      @ prow()+1,02 say 'Cliente....: ' + strzero(clicodi,3) + ' ' +  alltrim(clinome)
      @ prow()+1,02 say 'Fantasia...: ' + alltrim(clifant)                     
      @ prow()+1,02 say 'Endereco...: ' + cliende                     
      @ prow()+1,02 say 'Cidade.....: ' + clicida
      @ prow()+1,02 say 'UF.........: ' + cliuf__ + '                              CEP : ' + clicep_
      @ prow()+1,02 say 'CGC........: ' + clicgc_ + '              CF-DF : ' + clicf_d
      @ prow()+1,02 say 'Fones......: ' + clifon1 + ' ' + clifon2 + '       Fax  : ' + clifax_
      @ prow()+1,02 say 'Contato....: ' + clicont
      @ prow()+1,02 say 'Honorario..: ' + trans(clihono,'999,999.99') +  space(38) + ' Vencimento.: ' + strzero(clidia_,2)
      @ prow()+1,00 say''
      skip 
      if prow() > 54
         pag = pag + 1 ; titulo= .t.
         ejec 
      endif 
   enddo 
   eject
   set devi to screen 
   retu(2)

   case tecla = 74 .or. tecla = 106

      sombra(8,6,22,78)
      sele clientes
      go top
      if confirma(18,40,' 1 - Reajuste por Valor      ',' 2 - Reajuste por Percentual ')
         while .not. eof()
          sombra(8,6,22,78)
          matual = clihono
          @ 10,8 say 'Cliente...: ' + strzero(clicodi,3)  + ' ' + clinome
          @ 11,8 say 'Fantasia .: ' + clifant
          @ 12,8 say 'Honorario : ' + trans(clihono,'999,999.99')
          @ 13,8 say 'Atual.....:' get matual pict '999,999.99'
          read
          if matual # clihono
             if confirma(14,60,' 1 - Confirma ',' 2 - Cancela ')                
                replace clihono with matual
             endif
          endif
          skip
         enddo
      else
         mpercentual := 0
         @ 10,8  say 'Percentual :' get mpercentual pict '999.9999'
         read
         mpercentual = if(mpercentual=0,100,mpercentual/100)
         while .not. eof()
           matual = clihono + (clihono * mpercentual)
           @ 11,8 say 'Cliente....: ' + strzero(clicodi,3)  + ' ' + clinome
           @ 12,8 say 'Fantasia. .: ' + clifant
           @ 13,8 say 'Antigo.....: ' + trans(clihono,'999,999.99')
           replace clihono with matual
           @ 14,8 say 'Atual......: ' + trans(matual,'999,999.99')
           skip
         enddo
      endif
    retu(2)

   case tecla = 67 .or. tecla = 99

   if .not. impressora()
      retu(2)
   endif
   sombra(8,6,22,77,'Recibo','Esc-Cancela')
   mdata = date()
   sele clientes
   mmes       := space(20)
   mdevedora  := conta
   mcredora   := 6601
   mhistorico := 0
   mimprime   := 'N'
   @ 10,8 say 'Data       :' get mdata
   @ 11,8 say 'Referencia :' get mmes       pict '@!'
   @ 12,8 say 'Credora    :' get mcredora   pict '9999' valid(validaconta(mcredora,12,30))
   @ 13,8 say 'Historico  :' get mhistorico pict '999'  valid(validahisto(mhistorico,13,30))
   @ 14,8 say 'Imprime    :' get mimprime   pict '!'    valid mimprime $ 'SN'
   read
   if confirma(18,10,' 1 - Confirma ',' 2 - Cancela ',.t.)
      sele clientes
      go top
      while .not. eof() .and. esc()
       if clicodi > 499
          exit
       endif
       if clihono = 0
          skip
          loop
       endif
       mtotal := clihono
       mdevedora = conta
       set devi to screen
       @ 10,8 say 'Cliente    : ' + strzero(clicodi,3) + ' ' + clinome
       sele movito
       appe blank
       repla datala with mdata
       repla devedo with mdevedora
       repla credor with mcredora
       repla hplanc with mhistorico
       repla comple with mmes
       repla valorl with mtotal
       sele clientes
       if mimprime = 'N'
          skip
          loop
       endif
       set devi to printer
       @ prow()+1,02 say chr(18)
       @ prow()+8,20 say chr(27) + 'W' + '1'
       @ prow(),16    say 'R E C I B O '
       @ prow()+1,20 say chr(27) + 'W' + '0'
       @ prow()+2,60 say 'R$ : ' + trans(mtotal,'999,999,999.99')
       @ prow()+3,23 say 'Recebemos de ' + clinome + ' , a'
       @ prow()+1,10 say 'importancia supra de '
       extenso(prow(),31,mtotal)
       @ prow()+1,10 say 'para pagamento dos servicos relacionados abaixo :'
       @ prow()+1,10 say repli('-',70)
       @ prow()+1,32 say 'Honorarios do Mes : ' + mmes
       @ prow(),70   say mtotal pict '999,999.99'
       @ prow()+1,32 say '                                  =============='
       @ prow()+1,32 say 'Total............................:    ' + trans(mtotal,'999,999.99')
       @ prow()+1,10 say repli('-',70)
       @ prow()+2,38 say 'Taguatinga - DF, ' + datext(mdata) + '.'
       @ prow()+3,38 say '---------------------------------------'
       @ prow()+1,38 say '       Gomide - Contabilidade         '
       @ prow()+8,2  say ''
       skip
      enddo
   endif
   set devi to screen
   sele clientes
   retu(2)

   case tecla = 79 .or. tecla = 111

   if .not. impressora()
      retu(2)
   endif
   sombra(8,6,22,77,'Recibo de Honorario Advocaticio')
   mdata = date()
   sele clientes
   mmes       := space(20)
   mdevedora  := conta
   mcredora   := 6902
   mhistorico := 0
   mimprime   := 'N'
   @ 10,8 say 'Data       :' get mdata
   @ 11,8 say 'Referencia :' get mmes pict '@!'
   @ 12,8 say 'Credora    :' get mcredora pict '9999' valid(validaconta(mcredora,12,30))
   @ 13,8 say 'Historico  :' get mhistorico pict '999' valid(validahisto(mhistorico,13,30))
   @ 14,8 say 'Imprime    :' get mimprime   pict '!'    valid mimprime $ 'SN'
   read
   if confirma(18,10,' 1 - Confirma ',' 2 - Cancela ',.t.)
      sele clientes
      set softseek on
      seek 500
      set softseek off
      while .not. eof()
       mtotal := clihono
       mdevedora = conta
       set devi to screen
       @ 10,8 say 'Cliente    : ' + strzero(clicodi,3) + ' ' + clinome
       sele movito
       appe blank
       repla datala with mdata
       repla devedo with mdevedora
       repla credor with mcredora
       repla hplanc with mhistorico
       repla comple with mmes
       repla valorl with mtotal
       sele clientes
       if mimprime = 'N'
          skip
          loop
       endif
       set devi to printer
       @ prow()+12,20 say chr(27) + 'W' + '1'
       @ prow(),16    say 'R E C I B O '
       @ prow()+1,20 say chr(27) + 'W' + '0'
       @ prow()+2,60 say 'R$ : ' + trans(mtotal,'999,999,999.99')
       @ prow()+3,23 say 'Recebemos de ' + clinome + ' , a'
       @ prow()+1,10 say 'importancia supra de '
       extenso(prow(),31,mtotal)
       @ prow()+1,10 say 'para pagamento dos servicos relacionados abaixo :'
       @ prow()+1,10 say repli('-',70)
       @ prow()+1,10 say 'Honorarios Advocaticios do Mes : ' + mmes
       @ prow(),70   say mtotal pict '999,999.99'
       @ prow()+1,32 say '                                  =============='
       @ prow()+1,32 say 'Total............................:    ' + trans(mtotal,'999,999.99')
       @ prow()+1,10 say repli('-',70)
       @ prow()+2,38 say 'Taguatinga - DF, ' + datext(mdata) + '.'
       @ prow()+3,38 say '---------------------------------------'
       @ prow()+1,38 say '       Rogerio Gomide Castanheira     '
       @ prow()+1,38 say '             OAB - DF : 9036          '
       @ prow()+4,2  say ''
       skip
      enddo
   endif
   set devi to screen
   sele clientes
   retu(2)

  otherwise

    retu(1)

endcase



function telacli()

 @ 11,08 say 'Nome..........:' get mclinome
 @ 12,08 say 'Nome Fantasia :' get mclifant
 @ 13,08 say 'Endereco..... :' get mcliende
 @ 14,08 say 'Cidade....... :' get mclicida
 @ 14,69 say 'UF :' get mcliuf__ pict '@!'
 @ 15,08 say 'CEP :'get mclicep_ pict '99.999-999'
 @ 15,26 say 'CGC :' get mclicgc_  pict '##.###.###/####-##'
 @ 15,51 say 'CF-DF :' get mclicf_d pict '##.###.###/###-##'
 @ 16,08 say 'Fone1 :' get mclifon1 pict '999-999-9999'
 @ 16,34 say 'Fone2 :' get mclifon2 pict '999-999-9999'
 @ 16,58 say 'Fax :' get mclifax_ pict '999-999-9999' 
 @ 17,08 say 'Contato...... :' get mclicont 
 @ 18,08 say 'Honorario.... :' get mclihono pict '999,999,999.99'
 @ 18,46 say 'Dia de Vencto :' get mclidia_ pict '99' range 0,31
 @ 19,08 say 'Conta         :' get mconta   pict '9999' 
retu
